<?php
namespace app\serverfund\service\withdraw;

use \app\manage\service\ApiBase;
/**
 * @author:      李颖
 * @DateTime:    2017-08-31 11:11:16
 * @Description: 提现模块
 */
class Withdraw extends ApiBase
{


	protected $withdrawValidate = '\app\serverfund\validate\Withdraw';
    protected $withdrawLogic = '\app\serverfund\logic\Withdraw';

    /*我的 - 申请提现*/
    public function applyDrawwith(): array 
    {
    	$data = $this->haveIssetReceiveData(['user_id'=>0,'user_info'=>[],'type'=>' ','card_id'=>0,'card_info'=>[],'money'=>0,'update_ip'=>' ','app_id'=>0]);
    	$validate = validate($this->withdrawValidate);
        if(!$validate->check($data)){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('check_card_info')->check($data['card_info'])){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('check_user_info')->check($data['user_info'])){ return verify_err(null, $validate->getError()); }

    	return $this->stepRun($data, 'applyDrawwith', 'applyDrawwith', $this->withdrawValidate, $this->withdrawLogic);
    }

    /*我的 - 申请提现列表（分页）*/
    public function withdrawList(): array 
    {
    	$data = $this->haveIssetReceiveData(['user_id'=>0,'status'=>'','page'=>1,'listRows'=>15, 'time'=>''], ['']);
    	return $this->stepRun($data, 'withdrawList', 'withdrawList', $this->withdrawValidate, $this->withdrawLogic);
    }

    /*管理员 - 获取提现列表*/
    public function adminWithdrawList(): array 
    {
        $data = $this->haveIssetReceiveData(['user_id'=>'','status'=>'','page'=>1,'listRows'=>15,'keywords'=>''], ['']);
        return $this->stepRun($data, 'withdrawList', 'withdrawList', $this->withdrawValidate, $this->withdrawLogic);
    }

    /*管理员 - 审核提现*/
    public function auditWithdraw(): array 
    {
    	$data = $this->haveIssetReceiveData(['id'=>0, 'status'=>0, 'review_id'=>0, 'review_info'=>[], 'update_ip'=>' '], ['']);

    	$validate = validate($this->withdrawValidate);
        if(!$validate->scene('auditWithdraw')->check($data)){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('check_user_info')->check($data['review_info'])){ return verify_err(null, $validate->getError()); }

        return $this->stepRun($data, 'auditWithdraw', 'auditWithdraw', $this->withdrawValidate, $this->withdrawLogic);
    	
    }

    /*管理员 - 审核转账*/
    public function auditTransfer(): array 
    {
        $data = $this->haveIssetReceiveData(['id'=>0, 'status'=>0, 'transfer_id'=>0, 'transfer_info'=>[], 'update_ip'=>' ', 'app_id'=>0], ['']);
        
        $validate = validate($this->withdrawValidate);
        if(!$validate->scene('auditTransfer')->check($data)){ return verify_err(null, $validate->getError()); }
        if(!$validate->scene('check_user_info')->check($data['transfer_info'])){ return verify_err(null, $validate->getError()); }

        return $this->stepRun($data, 'auditTransfer', 'auditTransfer', $this->withdrawValidate, $this->withdrawLogic);
    }

}